<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>《机器学习》 西瓜书习题 第 7 章: 贝叶斯分类器 | 云玩家</title><meta name="keywords" content="机器学习,习题,西瓜书"><meta name="author" content="云玩家"><meta name="copyright" content="云玩家"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="习题7.1试使用极大似然法估算西瓜数据集 $3.0$ 中前 $3$ 个属性的类条件概率. 极大似然法即计算如何才能使结果出现的可能性最大, 因此类条件概率为其在数据集里出现的概率, 即$$P(X &#x3D; x\mid C &#x3D; c) &#x3D; \frac{|D_{X, x}|}{|D_{X, c}|}$$其中 $D_{X, x}$ 表示属性 $X$ 中取值为 $x$ 的集合, $D_{X,x}$ 表示属性 $X">
<meta property="og:type" content="article">
<meta property="og:title" content="《机器学习》 西瓜书习题 第 7 章: 贝叶斯分类器">
<meta property="og:url" content="http://yunist.cn/ML/watermelon_book/answer/7/index.html">
<meta property="og:site_name" content="云玩家">
<meta property="og:description" content="习题7.1试使用极大似然法估算西瓜数据集 $3.0$ 中前 $3$ 个属性的类条件概率. 极大似然法即计算如何才能使结果出现的可能性最大, 因此类条件概率为其在数据集里出现的概率, 即$$P(X &#x3D; x\mid C &#x3D; c) &#x3D; \frac{|D_{X, x}|}{|D_{X, c}|}$$其中 $D_{X, x}$ 表示属性 $X$ 中取值为 $x$ 的集合, $D_{X,x}$ 表示属性 $X">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://yunist.cn/ML/watermelon_book/answer/7/7.svg">
<meta property="article:published_time" content="2020-02-27T15:27:29.000Z">
<meta property="article:modified_time" content="2021-08-14T04:39:34.321Z">
<meta property="article:author" content="云玩家">
<meta property="article:tag" content="机器学习">
<meta property="article:tag" content="习题">
<meta property="article:tag" content="西瓜书">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://yunist.cn/ML/watermelon_book/answer/7/7.svg"><link rel="shortcut icon" href="/img/favicon.ico"><link rel="canonical" href="http://yunist.cn/ML/watermelon_book/answer/7/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//s4.cnzz.com"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script async="async" data-pjax="data-pjax" src="https://s4.cnzz.com/z_stat.php?id=1278869595&amp;web_id=1278869595"></script><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: false
}</script><script src="/js/yuntools.js"></script><script id="config-diff">var GLOBAL_CONFIG_SITE = { 
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2021-08-14 12:39:34'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    })(window)</script><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/cnyist/blog/css/font.css"><meta name="generator" content="Hexo 5.4.0"></head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" src="https://cdn.jsdelivr.net/gh/cnyist/blog/img/avatar.svg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">97</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">40</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">27</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/chat/"><i class="fa-fw fas fa-comments"></i><span> 闲聊室</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-user"></i><span> about</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw iconfont icon-Web"></i><span> 镜像站点</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" target="_blank" rel="noopener" href="https://yunist.gitee.io"><i class="fa-fw iconfont icon-gitee-fill-round"></i><span> Gitee Pages</span></a></li></ul></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('/ML/watermelon_book/answer/7/7.svg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">云玩家</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/chat/"><i class="fa-fw fas fa-comments"></i><span> 闲聊室</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-user"></i><span> about</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw iconfont icon-Web"></i><span> 镜像站点</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" target="_blank" rel="noopener" href="https://yunist.gitee.io"><i class="fa-fw iconfont icon-gitee-fill-round"></i><span> Gitee Pages</span></a></li></ul></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">《机器学习》 西瓜书习题 第 7 章: 贝叶斯分类器</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2020-02-27T15:27:29.000Z" title="发表于 2020-02-27 23:27:29">2020-02-27</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2021-08-14T04:39:34.321Z" title="更新于 2021-08-14 12:39:34">2021-08-14</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/">机器学习</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/%E8%A5%BF%E7%93%9C%E4%B9%A6/">西瓜书</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/%E8%A5%BF%E7%93%9C%E4%B9%A6/%E4%B9%A0%E9%A2%98/">习题</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span><span class="post-meta-separator">|</span><span class="post-meta-commentcount"><i class="far fa-comments fa-fw post-meta-icon"></i><span class="post-meta-label">评论数:</span><a href="/ML/watermelon_book/answer/7/#post-comment"><span id="twikoo-count"></span></a></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="习题"><a href="#习题" class="headerlink" title="习题"></a>习题</h1><h2 id="7-1"><a href="#7-1" class="headerlink" title="7.1"></a>7.1</h2><p><strong>试使用极大似然法估算西瓜数据集 $3.0$ 中前 $3$ 个属性的类条件概率.</strong></p>
<p>极大似然法即计算如何才能使结果出现的可能性最大, 因此类条件概率为其在数据集里出现的概率, 即<br>$$<br>P(X = x\mid C = c) = \frac{|D_{X, x}|}{|D_{X, c}|}<br>$$<br>其中 $D_{X, x}$ 表示属性 $X$ 中取值为 $x$ 的集合, $D_{X,x}$ 表示属性 $X$ 中类别为 $c$ 的集合.<br>所以前 $3$ 个属性的类条件概率为<br>$$<br>\begin{align}<br>P(X = 青绿\mid C = 是) = \frac{3}{8}, P(X = 乌黑\mid C = 是) = \frac{4}{8}, P(X = 浅白\mid C = 是) = \frac{1}{8}\\<br>P(X = 青绿\mid C = 否) = \frac{3}{9}, P(X = 乌黑\mid C = 否) = \frac{2}{9}, P(X = 浅白\mid C = 否) = \frac{4}{9}\\<br>P(X = 青绿\mid C = 否) = \frac{3}{9}, P(X = 乌黑\mid C = 否) = \frac{2}{9}, P(X = 浅白\mid C = 否) = \frac{4}{9}\\<br>P(X = 蜷缩\mid C = 是) = \frac{5}{8}, P(X = 稍蜷\mid C = 是) = \frac{3}{8}, P(X = 硬挺\mid C = 是) = \frac{0}{8}\\<br>P(X = 蜷缩\mid C = 否) = \frac{3}{9}, P(X = 稍蜷\mid C = 否) = \frac{4}{9}, P(X = 硬挺\mid C = 否) = \frac{2}{9}\\<br>P(X = 浊响\mid C = 是) = \frac{6}{8}, P(X = 沉闷\mid C = 是) = \frac{2}{8}, P(X = 清脆\mid C = 是) = \frac{0}{8}\\<br>P(X = 浊响\mid C = 否) = \frac{4}{9}, P(X = 沉闷\mid C = 否) = \frac{3}{9}, P(X = 清脆\mid C = 否) = \frac{2}{9}<br>\end{align}<br>$$</p>
<h2 id="7-2"><a href="#7-2" class="headerlink" title="7.2"></a>7.2</h2><p><strong>试证明: 条件独立性假设不成立时, 朴素贝叶斯分类器仍有可能产生最优贝叶斯分类器.</strong></p>
<p>原书 $\mathrm p.164$</p>
<blockquote>
<p>若属性间依赖对所有类别影响相同, 或依赖关系的影响能互相抵消, 则属性条件独立性假设在降低计算开销的同时不会对性能产生负面影响 $[\mathrm{Zhang}, 2004].$</p>
</blockquote>
<h2 id="7-3"><a href="#7-3" class="headerlink" title="7.3"></a>7.3</h2><p><strong>试编程实现拉普拉斯修正的朴素贝叶斯分类器, 并以西瓜数据集 $3.0$ 为训练集, 对 $\mathrm p.151$ “测 $1$” 样本进行判别.</strong></p>
<p><a target="_blank" rel="noopener" href="https://aistudio.baidu.com/aistudio/projectdetail/261652">https://aistudio.baidu.com/aistudio/projectdetail/261652</a></p>
<h2 id="7-4"><a href="#7-4" class="headerlink" title="7.4"></a>7.4</h2><p><strong>实践中使用式 $(7.15)$ 决定分类类别时, 若数据的维数非常高, 则概率连乘 $\prod_{i = 1}^{d}P(x_i\mid c)$ 的结果通常会非常接近于 $0$ 从而导致下溢. 试述防止下溢的可能方案.</strong></p>
<p>遇到问题, 要多查书. 书里其实已经给了解决方案, 那就是取对数.</p>
<h2 id="7-5"><a href="#7-5" class="headerlink" title="7.5"></a>7.5</h2><p><strong>试证明: 二分类任务中两类数据满足高斯分布且方差相同时, 线性判别分析产生贝叶斯最优分类器.</strong></p>
<p>我们先分析 $\mathrm{LDA}$ , 两类数据都满足高斯分布并且方差相同, 于是两类数据的形状是一样的, 只是所处位置不同. $\mathrm{LDA}$ 需要将样本中心的间隔最大化, 并且无论数据投影在哪一条直线上样本内方差都是一样的 (因为是个圆) , 所以应该会投射在一个与两个样本中心的连线平行的直线上 (此时样本中心相距最远). 在样本中心的连线的中点是两个类的分割点.</p>
<p>而贝叶斯会将在某个位置出现的点分成最可能的类, 这个最可能我们用样本来估计它的概率. 根据高斯分布, 距样本中心越远点的分布越少, 相应的概率也变小, 那么分界线在哪呢? (就是刚刚好分成 $1$ 类的概率是 $50%$, $0$ 类的概率也是 $50%$) 其实也是样本中心连线的中点, 更准确的说是过该点与样本中心连线的直线垂直的平面, 因为该平面上每一点与两个样本中心的距离都是相同的. </p>
<p>因此线性判别分析与贝叶斯产生了相同效果的分类界限, 于是它们是等价的.</p>
<h2 id="7-6"><a href="#7-6" class="headerlink" title="7.6"></a>7.6</h2><p><strong>试编程实现 $\mathrm {AODE}$ 分类器, 并以西瓜数据集 $3.0$ 为训练集, 对 $\mathrm p.151$ 的 “测 $1$” 样本进行判别.</strong></p>
<p><a target="_blank" rel="noopener" href="https://aistudio.baidu.com/aistudio/projectdetail/261652">https://aistudio.baidu.com/aistudio/projectdetail/261652</a></p>
<h2 id="7-7"><a href="#7-7" class="headerlink" title="7.7"></a>7.7</h2><p><strong>给定 $d$ 个二值属性的二分类任务, 假设对于任何先验概率项的估算至少需 $30$ 个样例, 则在朴素贝叶斯分类器式 $(7.15)$ 中估算先验概率项 $P(c)$ 需 $30\times 2 = 60$ 个样例. 试估计在 $\mathrm{AODE}$ 式 $(7.23)$ 中估算先验概率项 $P(c, x_i)$ 所需的样例数 (分别考虑最好和最坏情形).</strong></p>
<p>$$<br>P(c\mid \boldsymbol{x}) \propto \sum_{\begin{array}{c}\scriptstyle i = 1\\\scriptstyle|D_{x_i}|\geqslant m’ \end{array}}^{d}P(c, x_i)\prod_{j = 1}^d P(x_j\mid c, x_i)\tag{7.23}<br>$$<br>最好情形就是 $60$ 个了, 即 $x_i$ 只有两种取值并且和 $c$ 一起出现, 也就是<br>$$<br>P(c) = P(c, x_i)<br>$$<br>最坏情形则为 $30\times 2 \times i$ 个, 即每种情况各有 $30$ 个样例, 由于有两类, $i$ 个取值, 所以一共有 $2 \times i$ 种情况, 因此就为 $30\times 2 \times i$ 个.</p>
<h2 id="7-8"><a href="#7-8" class="headerlink" title="7.8"></a>7.8</h2><p><strong>考虑图 $7.3$ , 试证明: 在同父结构中, 若 $x_1$ 的取值未知, 则 $x_3\perp !!! \perp x_4$ 不成立; 在顺序结构中, $y \perp z \mid x$, 但 $y \perp !!! \perp z$ 不成立.</strong></p>
<p>在这里我就不得不得吐个槽, $\perp !!! \perp$这个符号实在是太难找, 只能用两个 $\perp$ 重叠来替代 <del>(所以如果见到两个接着的 $\perp$ 不要奇怪)</del>.<br><img src="1.png" alt="贝叶斯网中三个变量之间的典型依赖关系"><br>这里要用到的重要式子是<br>$$<br>P_B(x_1, x_2, \dots, x_d) = \prod_d^{i = 1}P_B(x_i\mid \pi_i) = \prod_{i = 1}^d \theta_{x{_i}\mid\pi_i}\tag{7.26}<br>$$<br>对同父结构来说, 由于 $x_1$ 已知, 我们设 $x_1 = x$ 因此 $P(x_1 = x) = 1$, 因此有<br>$$<br>\begin{aligned}<br>P(x_1 = x, x_3, x_4) &amp;= P(x_3\mid x_1 = x)P(x_4\mid x_1 = x)P(x_1 = x)\\<br>P(x_3, x_4) &amp;= P(x_3)P(x_4)<br>\end{aligned}<br>$$<br>即 $x_3 \perp x_4 \mid x_1$ .</p>
<p>而如果 $x_1$ 未知, 那么同样的有<br>$$<br>P(x_1, x_3, x_4) = P(x_3\mid x_1)P(x_4\mid x_1)P(x_1)<br>$$</p>
<p>$$<br>\begin{aligned}<br>P(x_3, x_4) &amp;= \sum_{i = 1}^mP(x_1 = x_1^i, x_3, x_4)\\<br>&amp;=\sum_{i = 1}^mP(x_3\mid x_1 = x_1^i)P(x_4\mid x_1 = x_1^i)P(x_1 = x_1^i)<br>\end{aligned}<br>$$</p>
<p>其中 $m$ 是 $x_1$ 可能的取值数, $x_1^i$ 是 $x_1$ 第 $i$ 个取值.<br>$$<br>P(x_3) = \sum_{i = 1}^mP(x_3\mid x_1 = x_1^i)\\<br>P(x_4) = \sum_{i = 1}^mP(x_4\mid x_1 = x_1^i)\\<br>$$<br>$$<br>\because \left[\sum_{i = 1}^mP(x_3\mid x_1 = x_1^i)\right]\left[\sum_{i = 1}^mP(x_4\mid x_1 = x_1^i)\right] \geqslant \sum_{i = 1}^mP(x_3\mid x_1 = x_1^i)P(x_4\mid x_1 = x_1^i)<br>$$</p>
<p>且<br>$$<br>P(x_1 = x_1^i) \leqslant 1<br>$$</p>
<p>$$<br>\begin{aligned}<br>\therefore \left[\sum_{i = 1}^mP(x_3\mid x_1 = x_1^i)\right]\left[\sum_{i = 1}^mP(x_4\mid x_1 = x_1^i)\right] &amp;\geqslant \sum_{i = 1}^mP(x_3\mid x_1 = x_1^i)P(x_4\mid x_1 = x_1^i)P(x_1 = x_1^i)P(x_1 = x_1^i)\\<br>P(x_3)P(x_4) &amp;\geqslant p(x_3, x_4)<br>\end{aligned}<br>$$</p>
<p>当且仅当 $x_1$ 已知时取等, 即 $x_1$ 未知时, $x_3\perp !!! \perp x_4$ 不成立.</p>
<p>对于顺序结构来说, 我们用同样的方法去证明.</p>
<p>若 $x$ 取值已知且值为 $a$, 则有<br>$$<br>P(x = a) = 1<br>$$<br>$$<br>\begin{aligned}<br>\therefore<br>P(x, y, z) &amp;= P(y\mid x)P(x\mid z)P(z)\\<br>P(y, z)&amp;= P(y) \times 1 \times P(z) = P(y)P(z)<br>\end{aligned}<br>$$</p>
<p>即 $y \perp z \mid x$</p>
<p>当 $x$ 取值未知时<br>$$<br>\begin{aligned}<br>P(y, z) &amp;= \sum_{i = 1}^mP(x = x_i, y, z)\\<br>&amp;=\sum_{i = 1}^mP(y\mid x = x_i)P(x = x_i\mid z)P(z)\\<br>&amp;=P(z)\sum_{i = 1}^mP(y\mid x = x_i)P(x = x_i\mid z)<br>\end{aligned}\\<br>P(y) = \sum_{i = 1}^mP(y\mid x = x_i)\\<br>\because P(x = x_i\mid z) \leqslant 1<br>$$<br>其中 $m$ 为 $x$ 取值数量, $x_i$ 为 $x$ 的第 $i$ 个取值.<br>$$<br>\therefore<br>\begin{aligned}<br>\sum_{i = 1}^mP(y\mid x = x_i) &amp;\geqslant \sum_{i = 1}^mP(y\mid x = x_i)P(x = x_i\mid z)\\<br>\sum_{i = 1}^mP(y\mid x = x_i)P(z) &amp;\geqslant P(z)\sum_{i = 1}^mP(y\mid x = x_i)P(x = x_i\mid z)\\<br>P(y)P(z)&amp;\geqslant P(y, z)<br>\end{aligned}<br>$$<br>当且仅当 $x$ 已知时取等, 即 $x$ 未知时, $y\perp !!! \perp z$ 不成立.</p>
<h2 id="7-9"><a href="#7-9" class="headerlink" title="7.9"></a>7.9</h2><p><strong>以西瓜数据集 $2.0$ 为训练集, 试基于 $\mathrm{BIC}$ 准则构建一个贝叶斯网.</strong></p>
<p><a target="_blank" rel="noopener" href="https://aistudio.baidu.com/aistudio/projectdetail/261652">https://aistudio.baidu.com/aistudio/projectdetail/261652</a></p>
<h2 id="7-10"><a href="#7-10" class="headerlink" title="7.10"></a>7.10</h2><p><strong>以西瓜数据集 $2.0$ 中属性 “脐部” 为隐变量, 试基于 $\mathrm{EM}$ 算法构建一个贝叶斯网.</strong></p>
<p><a target="_blank" rel="noopener" href="https://aistudio.baidu.com/aistudio/projectdetail/261652">https://aistudio.baidu.com/aistudio/projectdetail/261652</a></p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">云玩家</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://yunist.cn/ML/watermelon_book/answer/7/">http://yunist.cn/ML/watermelon_book/answer/7/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://yunist.cn" target="_blank">云玩家</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/">机器学习</a><a class="post-meta__tags" href="/tags/%E4%B9%A0%E9%A2%98/">习题</a><a class="post-meta__tags" href="/tags/%E8%A5%BF%E7%93%9C%E4%B9%A6/">西瓜书</a></div><div class="post_share"><div class="social-share" data-image="/ML/watermelon_book/answer/7/7.svg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><!-- - var pagination_cover = prev.cover === false ? prev.randomcover : prev.cover--><a href="/hexo/problem_in_Valine/"><img class="prev-cover" src="https://cdn.jsdelivr.net/gh/cnyist/blog/hexo/problem_in_Valine/problem_in_Valine.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">解决 Hexo 配置 Valine 各种问题</div></div></a></div><!-- - var pagination_cover = next.cover == false ? next.randomcover : next.cover--><div class="next-post pull-right"><a href="/python/jupyter/jupyter_formula_render/"><img class="next-cover" src="https://cdn.jsdelivr.net/gh/cnyist/blog/python/jupyter/jupyter_formula_render/jupyter_formula_render.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">Jupyter 公式渲染问题</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/ML/watermelon_book/answer/1/" title="《机器学习》 西瓜书习题 第 1 章: 绪论"><img class="cover" src="https://cdn.jsdelivr.net/gh/cnyist/blog/ML/watermelon_book/answer/1/1.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-02-26</div><div class="title">《机器学习》 西瓜书习题 第 1 章: 绪论</div></div></a></div><div><a href="/ML/watermelon_book/answer/2/" title="《机器学习》 西瓜书习题 第 2 章: 模型评估与选择"><img class="cover" src="https://cdn.jsdelivr.net/gh/cnyist/blog/ML/watermelon_book/answer/2/2.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-02-26</div><div class="title">《机器学习》 西瓜书习题 第 2 章: 模型评估与选择</div></div></a></div><div><a href="/ML/watermelon_book/answer/3/" title="《机器学习》 西瓜书习题 第 3 章: 线性模型"><img class="cover" src="https://cdn.jsdelivr.net/gh/cnyist/blog/ML/watermelon_book/answer/3/3.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-02-26</div><div class="title">《机器学习》 西瓜书习题 第 3 章: 线性模型</div></div></a></div><div><a href="/ML/watermelon_book/answer/4/" title="《机器学习》 西瓜书习题 第 4 章: 决策树"><img class="cover" src="https://cdn.jsdelivr.net/gh/cnyist/blog/ML/watermelon_book/answer/4/4.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-02-26</div><div class="title">《机器学习》 西瓜书习题 第 4 章: 决策树</div></div></a></div><div><a href="/ML/watermelon_book/answer/5/" title="《机器学习》 西瓜书习题 第 5 章: 神经网络"><img class="cover" src="https://cdn.jsdelivr.net/gh/cnyist/blog/ML/watermelon_book/answer/5/5.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-02-26</div><div class="title">《机器学习》 西瓜书习题 第 5 章: 神经网络</div></div></a></div><div><a href="/ML/watermelon_book/answer/6/" title="《机器学习》 西瓜书习题 第 6 章: 支持向量机"><img class="cover" src="https://cdn.jsdelivr.net/gh/cnyist/blog/ML/watermelon_book/answer/6/6.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-02-26</div><div class="title">《机器学习》 西瓜书习题 第 6 章: 支持向量机</div></div></a></div></div></div><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div id="twikoo-wrap"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="card-info-avatar is-center"><img class="avatar-img" src="https://cdn.jsdelivr.net/gh/cnyist/blog/img/avatar.svg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/><div class="author-info__name">云玩家</div><div class="author-info__description">云玩家's blog</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">97</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">40</div></a></div><div class="card-info-data-item is-center"><a href="/categories/"><div class="headline">分类</div><div class="length-num">27</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/xxxxxx"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/cnyist" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="https://blog.csdn.net/chnyist" target="_blank" title="CSDN"><i class="fas iconfont icon-CN_csdnnet"></i></a><a class="social-icon" href="https://www.zhihu.com/people/cnyist" target="_blank" title="知乎"><i class="fas iconfont icon-zhihu"></i></a><a class="social-icon" href="mailto:yunist@qq.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%B9%A0%E9%A2%98"><span class="toc-number">1.</span> <span class="toc-text">习题</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#7-1"><span class="toc-number">1.1.</span> <span class="toc-text">7.1</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-2"><span class="toc-number">1.2.</span> <span class="toc-text">7.2</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-3"><span class="toc-number">1.3.</span> <span class="toc-text">7.3</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-4"><span class="toc-number">1.4.</span> <span class="toc-text">7.4</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-5"><span class="toc-number">1.5.</span> <span class="toc-text">7.5</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-6"><span class="toc-number">1.6.</span> <span class="toc-text">7.6</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-7"><span class="toc-number">1.7.</span> <span class="toc-text">7.7</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-8"><span class="toc-number">1.8.</span> <span class="toc-text">7.8</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-9"><span class="toc-number">1.9.</span> <span class="toc-text">7.9</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-10"><span class="toc-number">1.10.</span> <span class="toc-text">7.10</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><!-- - let post_cover = article.cover--><div class="aside-list-item"><a class="thumbnail" href="/math/set_theory/unique_ordinal/" title="序数的唯一性"><img src="https://cdn.jsdelivr.net/gh/cnyist/blog/math/set_theory/unique_ordinal/unique_ordinal.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="序数的唯一性"/></a><div class="content"><a class="title" href="/math/set_theory/unique_ordinal/" title="序数的唯一性">序数的唯一性</a><time datetime="2022-01-12T08:26:12.000Z" title="发表于 2022-01-12 16:26:12">2022-01-12</time></div></div><!-- - let post_cover = article.cover--><div class="aside-list-item"><a class="thumbnail" href="/math/mathematical_analysis/mathematical_analysis_practice/3/3-1/" title="(史济怀) 数学分析教程上册第 3 版-练习题 3.1"><img src="https://cdn.jsdelivr.net/gh/cnyist/blog/math/mathematical_analysis/mathematical_analysis_practice/3/3-1/math.jpeg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="(史济怀) 数学分析教程上册第 3 版-练习题 3.1"/></a><div class="content"><a class="title" href="/math/mathematical_analysis/mathematical_analysis_practice/3/3-1/" title="(史济怀) 数学分析教程上册第 3 版-练习题 3.1">(史济怀) 数学分析教程上册第 3 版-练习题 3.1</a><time datetime="2021-10-19T00:30:55.000Z" title="发表于 2021-10-19 08:30:55">2021-10-19</time></div></div><!-- - let post_cover = article.cover--><div class="aside-list-item"><a class="thumbnail" href="/math/mathematical_analysis/mathematical_analysis_practice/2/2-11/" title="(史济怀) 数学分析教程上册第 3 版-练习题 2.11"><img src="https://cdn.jsdelivr.net/gh/cnyist/blog/math/mathematical_analysis/mathematical_analysis_practice/2/2-11/2-11.jpeg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="(史济怀) 数学分析教程上册第 3 版-练习题 2.11"/></a><div class="content"><a class="title" href="/math/mathematical_analysis/mathematical_analysis_practice/2/2-11/" title="(史济怀) 数学分析教程上册第 3 版-练习题 2.11">(史济怀) 数学分析教程上册第 3 版-练习题 2.11</a><time datetime="2021-09-25T03:37:28.000Z" title="发表于 2021-09-25 11:37:28">2021-09-25</time></div></div><!-- - let post_cover = article.cover--><div class="aside-list-item"><a class="thumbnail" href="/math/mathematical_analysis/mathematical_analysis_practice/2/2-10/" title="(史济怀) 数学分析教程上册第 3 版-练习题 2.10"><img src="https://cdn.jsdelivr.net/gh/cnyist/blog/math/mathematical_analysis/mathematical_analysis_practice/2/2-10/2-10.jpeg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="(史济怀) 数学分析教程上册第 3 版-练习题 2.10"/></a><div class="content"><a class="title" href="/math/mathematical_analysis/mathematical_analysis_practice/2/2-10/" title="(史济怀) 数学分析教程上册第 3 版-练习题 2.10">(史济怀) 数学分析教程上册第 3 版-练习题 2.10</a><time datetime="2021-09-22T07:36:49.000Z" title="发表于 2021-09-22 15:36:49">2021-09-22</time></div></div><!-- - let post_cover = article.cover--><div class="aside-list-item"><a class="thumbnail" href="/math/mathematical_analysis/mathematical_analysis_practice/2/2-9/" title="(史济怀) 数学分析教程上册第 3 版-练习题 2.9"><img src="https://cdn.jsdelivr.net/gh/cnyist/blog/math/mathematical_analysis/mathematical_analysis_practice/2/2-9/2-9.jpeg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="(史济怀) 数学分析教程上册第 3 版-练习题 2.9"/></a><div class="content"><a class="title" href="/math/mathematical_analysis/mathematical_analysis_practice/2/2-9/" title="(史济怀) 数学分析教程上册第 3 版-练习题 2.9">(史济怀) 数学分析教程上册第 3 版-练习题 2.9</a><time datetime="2021-09-20T08:19:06.000Z" title="发表于 2021-09-20 16:19:06">2021-09-20</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2022 By 云玩家</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer><script>document.getElementById('web_bg').style = 'background-image: url("' + get_rand_jsd_pic('cnyist', 'banner@master', '/', 70, '-min.jpg') + '")'</script></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/search/local-search.js"></script><div class="js-pjax"><script>if (!window.MathJax) {
  window.MathJax = {
    loader: {
      source: {
        '[tex]/amsCd': '[tex]/amscd'
      }
    },
    tex: {
      inlineMath: [ ['$','$'], ["\\(","\\)"]],
      tags: 'ams'
    },
    options: {
      renderActions: {
        findScript: [10, doc => {
          for (const node of document.querySelectorAll('script[type^="math/tex"]')) {
            const display = !!node.type.match(/; *mode=display/)
            const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display)
            const text = document.createTextNode('')
            node.parentNode.replaceChild(text, node)
            math.start = {node: text, delim: '', n: 0}
            math.end = {node: text, delim: '', n: 0}
            doc.math.push(math)
          }
        }, ''],
        addClass: [200,() => {
          document.querySelectorAll('mjx-container:not([display=\'true\']').forEach( node => {
            const target = node.parentNode
            if (!target.classList.contains('has-jax')) {
              target.classList.add('mathjax-overflow')
            }
          })
        }, '', false]
      }
    }
  }
  
  const script = document.createElement('script')
  script.src = 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js'
  script.id = 'MathJax-script'
  script.async = true
  document.head.appendChild(script)
} else {
  MathJax.startup.document.state(0)
  MathJax.texReset()
  MathJax.typeset()
}</script><script>(()=>{
  const $countDom = document.getElementById('twikoo-count')
  const init = () => {
    let initData = {
      el: '#twikoo-wrap',
      envId: 'yunist-147dfe',
      region: ''
    }

    if (false) {
      const otherData = false
      initData = Object.assign(initData, otherData)
    }
    
    twikoo.init(initData)
  }

  const getCount = () => {
    twikoo.getCommentsCount({
      envId: 'yunist-147dfe',
      region: '',
      urls: [window.location.pathname],
      includeReply: false
    }).then(function (res) {
      $countDom.innerText = res[0].count
    }).catch(function (err) {
      console.error(err);
    });
  }

  const loadTwikoo = (bool = false) => {
    if (typeof twikoo === 'object') {
      init()
      bool && $countDom && setTimeout(getCount,0)
    } else {
      getScript('https://cdn.jsdelivr.net/npm/twikoo/dist/twikoo.all.min.js').then(()=> {
        init()
        bool && $countDom && setTimeout(getCount,0)
      })
    }
  }

  if ('Twikoo' === 'Twikoo' || !false) {
    if (false) btf.loadComment(document.getElementById('twikoo-wrap'), loadTwikoo)
    else loadTwikoo(true)
  } else {
    window.loadOtherComment = () => {
      loadTwikoo()
    }
  }
})()</script></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>